package gov.child.entities.po;

import gov.child.entities.vo.annotation.Alias;
import gov.child.entities.vo.annotation.IgnoreField;

import javax.persistence.*;
import java.util.Date;

/**
 * @author fzh
 * @since 2017/9/16
 */
@Entity
@Table(name = "personal_declare_form", schema = "gov_c")
public class EPersonalDeclareForm {
    @Alias("personalDeclareFormId")
    private Integer id;
    private String uniformCode;
    private Integer userId;
    private String personalMaterial;
    private Byte status;
    @IgnoreField
    private EUser userByUserId;
    private Date createTime;
    private Integer guideId;
    @IgnoreField
    private EGuide guideByGuideId;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id", nullable = false)
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Basic
    @Column(name = "uniform_code", nullable = false, length = 60)
    public String getUniformCode() {
        return uniformCode;
    }

    public void setUniformCode(String uniformCode) {
        this.uniformCode = uniformCode;
    }

    @Basic
    @Column(name = "user_id", nullable = false)
    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    @Basic
    @Column(name = "guide_id", nullable = false)
    public Integer getGuideId() {
        return guideId;
    }

    public void setGuideId(Integer guideId) {
        this.guideId= guideId;
    }

    @Basic
    @Column(name = "personal_material", nullable = true, length = 60)
    public String getPersonalMaterial() {
        return personalMaterial;
    }

    public void setPersonalMaterial(String personalMaterial) {
        this.personalMaterial = personalMaterial;
    }

    @Basic
    @Column(name = "status", nullable = true)
    public Byte getStatus() {
        return status;
    }

    public void setStatus(Byte status) {
        this.status = status;
    }

    @Basic
    @Column(name = "create_time", nullable = true)
    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        EPersonalDeclareForm form = (EPersonalDeclareForm) o;

        if (id != null ? !id.equals(form.id) : form.id != null) return false;
        if (uniformCode != null ? !uniformCode.equals(form.uniformCode) : form.uniformCode != null) return false;
        if (userId != null ? !userId.equals(form.userId) : form.userId != null) return false;
        if (personalMaterial != null ? !personalMaterial.equals(form.personalMaterial) : form.personalMaterial != null)
            return false;
        if (status != null ? !status.equals(form.status) : form.status != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (uniformCode != null ? uniformCode.hashCode() : 0);
        result = 31 * result + (userId != null ? userId.hashCode() : 0);
        result = 31 * result + (personalMaterial != null ? personalMaterial.hashCode() : 0);
        result = 31 * result + (status != null ? status.hashCode() : 0);
        return result;
    }

    @ManyToOne
    @JoinColumn(name = "user_id", referencedColumnName = "id", nullable = false, insertable = false, updatable = false)
    public EUser getUserByUserId() {
        return userByUserId;
    }

    public void setUserByUserId(EUser userByUserId) {
        this.userByUserId = userByUserId;
    }
    @ManyToOne
    @JoinColumn(name = "guide_id", referencedColumnName = "id", nullable = false, insertable = false, updatable = false)
    public EGuide getGuideByGuideId() {
        return guideByGuideId;
    }

    public void setGuideByGuideId(EGuide guideByGuideId) {
        this.guideByGuideId = guideByGuideId;
    }
}
